package cn.itsource.org.mapper;

import cn.itsource.basic.mysuper.MyBaseMapper;
import cn.itsource.org.domain.Employee;
import tk.mybatis.mapper.entity.Example;


import java.util.List;

public interface EmployeeMapper extends MyBaseMapper<Employee>  {
    //一定要重写这个方法
    default  Class<Employee> getTClass(){
        return Employee.class;
    }

    Employee findOne(Long id);

    List<Employee> findall();

    default Employee login(Employee employee) {
        Example example = new Example(getTClass());
        example.createCriteria()
                .andEqualTo("username",employee.getUsername())
                .orEqualTo("email",employee.getUsername())
                .orEqualTo("phone",employee.getUsername());
        return this.selectOneByExample(example);
    }

    default List<Employee> findByShopId(Long shopId){
        Example example = new Example(getTClass());
        example.createCriteria()
                .andEqualTo("shopId",shopId);
        return this.selectByExample(example);
    };
}
